<template>
    <div class="mask">
        <div class="J-weixin-tip weixin-tip">
            <div class="weixin-tip-content">
                请在菜单中选择在浏览器中打开,<br/>
                以完成支付
            </div>
        </div>
        <div class="J-weixin-tip-img weixin-tip-img"></div>
    </div>
</template>

<script>
    export default {
        name: 'pay-alipay',
        data() {
            return {
                isWeiXi: true,
                theRequest: {}
            }
        },
        methods: {
            weixinTip(ele){
                if (location.hash.indexOf('error') != -1) {
                    alert('参数错误,请检查');
                } else {
                    console.log('11111111')
                    var ua = navigator.userAgent.toLowerCase();
                    console.log(ua.indexOf('micromessenger'))
                    var tip = document.querySelector(".weixin-tip");
                    var tipImg = document.querySelector(".J-weixin-tip-img");
                    if (ua.indexOf('micromessenger') != -1) {
                        // console.log('2222222')
                        tip.style.display = 'block';
                        tipImg.style.display = 'block';
                        if (ua.indexOf('iphone') != -1 || ua.indexOf('ipad') != -1 || ua.indexOf('ipod') != -1) {
                            tipImg.className = 'J-weixin-tip-img weixin-tip-img iphone'
                        } else {
                            tipImg.className = 'J-weixin-tip-img weixin-tip-img android'
                        }
                    } else {
                        // console.log('333333333333')
                        var getQueryString = function (url, name) {
                            var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
                            console.log('reg.test', reg.test(url))
                            if (reg.test(url)) return RegExp.$2.replace(/\+/g, " ");
                        };
                        var param = getQueryString(location.href, 'goto') || '';
                        location.href = param != '' ? _AP.decode(param) : 'pay.htm#error';
                    }
                }
            }
        },
        created() {
            
        },
        mounted() {
            // this.weixinTip()
            if (location.hash.indexOf('error') != -1) {
                alert('参数错误，请检查');
            } else {
                var ua = navigator.userAgent.toLowerCase();
                var tip = document.querySelector(".weixin-tip");
                var tipImg = document.querySelector(".J-weixin-tip-img");
                if (ua.indexOf('micromessenger') != -1) {
                    tip.style.display = 'block';
                    tipImg.style.display = 'block';
                    if (ua.indexOf('iphone') != -1 || ua.indexOf('ipad') != -1 || ua.indexOf('ipod') != -1) {
                        tipImg.className = 'J-weixin-tip-img weixin-tip-img iphone'
                    } else {
                        tipImg.className = 'J-weixin-tip-img weixin-tip-img android'
                    }
                } else {
                    var getQueryString = function (url, name) {
                        var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
                        if (reg.test(url)) return RegExp.$2.replace(/\+/g, " ");
                    };
                    var param = getQueryString(location.href, 'goto') || '';
                    location.href = param != '' ? _AP.decode(param) : 'pay.htm#error';
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .weixin-tip {
        display: none;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        position: absolute;
        top: 15px;
        right: 20px;
        width: 265px;
        padding: 55px 0 0;
        text-align: left;
        background: url() no-repeat right top;
        background-size: 45px 68px
    }

    .weixin-tip-img {
        display: none;
        padding: 110px 0 0
    }

    .weixin-tip-img::after {
        display: block;
        margin: 15px auto;
        content: ' ';
        background-size: cover
    }

    .weixin-tip-img.iphone::after {
        width: 150px;
        height: 150px;
        background-image: url()
    }

    .weixin-tip-img.android::after {
        width: 173px;
        height: 240px;
        background-image: url()
    }
</style>
